//
//  Home_ZP_04TableViewCell.m
//  MagicBox
//
//  Created by dllo on 16/8/11.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "Home_ZP_04TableViewCell.h"
#import "Home_ZP_04CollectionViewCell.h"
#import "HomePage_WebViewController.h"

@interface Home_ZP_04TableViewCell()<UICollectionViewDelegate,UICollectionViewDataSource>
@property (nonatomic, retain) UICollectionView *collection;
@property (nonatomic, retain) NSMutableArray *funArray;

@property (nonatomic, retain) NSMutableArray *imageArr;

@end



@implementation Home_ZP_04TableViewCell
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        
    }
    return self;
}









-(void)setMuArray:(NSMutableArray *)muArray{
    self.imageArr = [NSMutableArray arrayWithObjects:@"weizhang_thirdutility@3x.png",@"qiangui_thirdutility@3x.png",@"daikuan_thirdutility@3x.png",@"didi_thirdutility@3x.png",@"huochepiao_thirdutility@3x.png",@"piaowu_thirdutility@3x.png",@"gongjiao_thirdutility@3x.png",@"fangdai_thirdutility@3x.png",@"caipiao_thirdutility@3x.png",@"yiliao_thirdutility@3x.png",@"dianyingpiao_thirdutility@3x.png",@"wannianli_thirdutility@3x.png",@"aichegujia_thirdutility@3x.png",@"menpiao_thirdutility@3x.png",@"jiudian_thirdutility@3x.png",@"jiaxiao_thirdutility@3x.png",@"jiaofei_thirdutility@3x.png",@"daijia_thirdutility@3x.png",@"banjiatong_thirdutility@3x.png",@"yanchu_thirdutility@3x.png",@"xinyongka_thirdutility@3x.png",@"shangcheng_thirdutility@3x.png",nil];
    self.funArray = [NSMutableArray array];
    
    _muArray = muArray;
    self.funArray = _muArray;
    
    [self creactCollection];
}

-(void)creactCollection{
    
    UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc]init];
    layout.itemSize = CGSizeMake(SCREENWIDTH/6,SCREENHEIGHT/9);
    layout.minimumLineSpacing = 5;
    layout.minimumInteritemSpacing = 5;
    layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
    self.collection = [[UICollectionView alloc]initWithFrame:CGRectMake(0, 0, SCREENWIDTH, SCREENHEIGHT/4) collectionViewLayout:layout];

    self.collection.backgroundColor = [UIColor whiteColor];
    self.collection.delegate = self;
    self.collection. dataSource =self;


    [self.contentView addSubview:_collection];
    
    
    [self.collection registerClass:[Home_ZP_04CollectionViewCell class] forCellWithReuseIdentifier:@"cell"];
    
}
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
    
    return self.funArray.count;

    
}
-(UICollectionViewCell*)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
    Home_ZP_04CollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"cell" forIndexPath:indexPath];
    cell.model = [self.funArray objectAtIndex:indexPath.row];
    cell.imageStr = [self.imageArr objectAtIndex:indexPath.row];
    
    return cell;
}
-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
    switch (indexPath.item) {
        case 0:{
            HomePage_WebViewController *hwvc =[[HomePage_WebViewController alloc]init];
            hwvc.urlStr =@"http://tools.58.com/traffic.shtml?PGTID=0d100000-0009-3d16-c190-9243f8caa6f4&ClickID=1";
            [[self naviController]pushViewController:hwvc animated:YES];
            
        }
            break;
        case 1:{
            HomePage_WebViewController *hwvc =[[HomePage_WebViewController alloc]init];
            hwvc.urlStr =@"https://qiangui.58.com/cfloanmoney/show?src=B9551CD3D862F26FF8554293E4533C60";
            [[self naviController]pushViewController:hwvc animated:YES];
            
        }
            break;
        case 2:{
            HomePage_WebViewController *hwvc =[[HomePage_WebViewController alloc]init];
            hwvc.urlStr =@"http://jinrong.58.com/m/loan/k?city=dl&from=58_app_index&cid=147&os=android";
            [[self naviController]pushViewController:hwvc animated:YES];
            
        }
            break;
        case 3:{
            HomePage_WebViewController *hwvc =[[HomePage_WebViewController alloc]init];
            hwvc.urlStr =@"http://common.diditaxi.com.cn/general/webEntry?from=sdkwebapp&hack=allbiz&openid=TmpRNE5UUXhNVFEyT1RFNA%3D%3D&channel=70725&timestamp=1470966918&sign=fefab459f008bbdbd6a1a1a74e9b3bc31470966918&fromlat=22.546161&fromlng=114.070907&maptype=baidu";
            [[self naviController]pushViewController:hwvc animated:YES];
            
        }
            break;
        case 4:{
            HomePage_WebViewController *hwvc =[[HomePage_WebViewController alloc]init];
            hwvc.urlStr =@"http://m.tieyou.com/jy/index.php?param=default/home.html&utm_source=58&os=android";
            [[self naviController]pushViewController:hwvc animated:YES];
            
        }
            break;
        case 5:{
            HomePage_WebViewController *hwvc =[[HomePage_WebViewController alloc]init];
            hwvc.urlStr =@"https://loan.rongba.com/Calculator/income?cid=147&os=android";
            [[self naviController]pushViewController:hwvc animated:YES];
            
        }
            break;
        case 6:{
            HomePage_WebViewController *hwvc =[[HomePage_WebViewController alloc]init];
            hwvc.urlStr =@"http://web.chelaile.net.cn/ch5/index.html?showFav=0&showAllCity=1&hideFooter=1&src=webapp_58_Utilitytool&utm_source=webapp_58_Utilitytool&utm_medium=entrance&homePage=around&src=webapp_58_Utilitytool&lon=114.070907&lat=22.546161&owner=baidu";
            [[self naviController]pushViewController:hwvc animated:YES];
            
        }
            break;
        case 7:{
            HomePage_WebViewController *hwvc =[[HomePage_WebViewController alloc]init];
            hwvc.urlStr =@"http://www.baidu.com";
            [[self naviController]pushViewController:hwvc animated:YES];
            
        }
            break;
        case 8:{
            HomePage_WebViewController *hwvc =[[HomePage_WebViewController alloc]init];
            hwvc.urlStr =@"http://caipiao.m.58.com/app/home/index.html?from=58_app_index_sygj&cid=147";
            [[self naviController]pushViewController:hwvc animated:YES];
            
        }
            break;
        case 9:{
            HomePage_WebViewController *hwvc =[[HomePage_WebViewController alloc]init];
            hwvc.urlStr =@"http://58.wy.guahao.com/?lon=114.070907&lat=22.546161&owner=baidu";
            [[self naviController]pushViewController:hwvc animated:YES];
            
        }
            break;
        case 10:
        {
            HomePage_WebViewController *hwvc =[[HomePage_WebViewController alloc]init];
            hwvc.urlStr =@"http://h5.m.taobao.com/app/movie/pages/index/index.html?from=58tc";
            [[self naviController]pushViewController:hwvc animated:YES];
        }
            break;
            
        case 11:
        {
            HomePage_WebViewController *hwvc =[[HomePage_WebViewController alloc]init];
            hwvc.urlStr =@"http://platform.58.com/calendar/index?cid=147&os=android";
            [[self naviController]pushViewController:hwvc animated:YES];
        }
            break;
        case 12:{
            HomePage_WebViewController *hwvc =[[HomePage_WebViewController alloc]init];
            hwvc.urlStr =@"http://carprice.m.58.com/?from=app_index_btn_aichegujia&clientsrc=301&lon=114.070907&lat=22.546161&owner=baidu";
            [[self naviController]pushViewController:hwvc animated:YES];
        }
            break;
        case 13:{
            HomePage_WebViewController *hwvc =[[HomePage_WebViewController alloc]init];
            hwvc.urlStr =@"http://m.ctrip.com/webapp/ticket/index?allianceid=17582&sid=443445&sourceid=2131&lon=114.070907&lat=22.546161&owner=baidu";
            [[self naviController]pushViewController:hwvc animated:YES];
            
        }
            break;
        case 14:{
            HomePage_WebViewController *hwvc =[[HomePage_WebViewController alloc]init];
            hwvc.urlStr =@"http://u.ctrip.com/union/CtripRedirect.aspx?TypeID=636&sid=443445&allianceid=17582&ouid=&lon=114.070907&lat=22.546161&owner=baidu";
            [[self naviController]pushViewController:hwvc animated:YES];
            
        }
            break;
        case 15:{
            HomePage_WebViewController *hwvc =[[HomePage_WebViewController alloc]init];
            hwvc.urlStr =@"http://m.jxedt.com/index-58.asp?mobile=iphone&source=58app";
            [[self naviController]pushViewController:hwvc animated:YES];
            
        }
            break;
        case 16:{
            HomePage_WebViewController *hwvc =[[HomePage_WebViewController alloc]init];
            hwvc.urlStr =@"http://web.yiqianlian.com/mobile/mobileindex/58?os=android";
            [[self naviController]pushViewController:hwvc animated:YES];
            
        }
            break;
        case 17:{
            HomePage_WebViewController *hwvc =[[HomePage_WebViewController alloc]init];
            hwvc.urlStr =@"http://h5.edaijia.cn/app/index.html?from=01050031&lon=114.070907&lat=22.546161&owner=baidu&os=android";
            [[self naviController]pushViewController:hwvc animated:YES];
            
        }
            break;
        case 18:{
            HomePage_WebViewController *hwvc =[[HomePage_WebViewController alloc]init];
            hwvc.urlStr =@"http://m.baojia.com/58/?utm_source=58&utm_medium=app_shouye&utm_term=%E5%AE%9E%E7%94%A8%E5%B7%A5%E5%85%B7&utm_content=%E7%A7%9F%E8%BD%A6%E7%A5%9E%E5%99%A8&utm_campaign=shouye?&lon=114.070907&lat=22.546161&owner=baidu&os=android";
            [[self naviController]pushViewController:hwvc animated:YES];
            
        }
            break;
        case 19:{
            HomePage_WebViewController *hwvc =[[HomePage_WebViewController alloc]init];
            hwvc.urlStr =@"http://m.ypiao.com/?os=android";
            [[self naviController]pushViewController:hwvc animated:YES];
            
        }
            break;
        case 20:{
            HomePage_WebViewController *hwvc =[[HomePage_WebViewController alloc]init];
            hwvc.urlStr =@"http://xyk.58.com/bank/login?redirect=http%3A%2F%2Fxyk.58.com%2F";
            [[self naviController]pushViewController:hwvc animated:YES];
            
        }
            break;
        case 21:{
            HomePage_WebViewController *hwvc =[[HomePage_WebViewController alloc]init];
            hwvc.urlStr =@"http://xyk.58.com/bank/login?redirect=http%3A%2F%2Fxyk.58.com%2F";
            [[self naviController]pushViewController:hwvc animated:YES];
            
        }
            break;
    }





}
- (UINavigationController*)naviController {
    
    for (UIView* next = [self superview]; next; next = next.superview) {
        
        UIResponder* nextResponder = [next nextResponder];
        
        if ([nextResponder isKindOfClass:[UINavigationController class]]) {
            
            return (UINavigationController*)nextResponder;
        }
    }
    return nil;
}
@end
